<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <link rel="stylesheet" type="text/css" href="/static/css/top.css"/>
    <link rel="stylesheet" type="text/css" href="/static/css/newmain.css"/>
    <link href="favicon.ico" rel="shortcut icon">
    <link href="/static/css/fSelect.css" type="text/css" rel="stylesheet">
    <title>{{.sysname}}</title>
</head>
{{template "top.html" .}}
<body class="camslist_body">

{{$UID := .uid}}
{{$st :=.st}}
{{$an :=.an}}
{{$sk :=.sk}}
{{$as :=.as}}
{{$t :=.t}}
{{$MaxAlgoNum :=.MaxAlgoNum}}
{{$MaxVideoNum :=.MaxVideoNum}}
{{$PageNo := .PageNo}}
<div class="tbarlist">
    <div class="modal-headers">&nbsp;&nbsp;提示：机器最多可以开启算法数量：{{$MaxAlgoNum}}，单个算法可支持的摄像头数量：{{$MaxVideoNum}} </div>

    <div class="box-search">
        <form class="search_form">
            <label class="label">算法名称&nbsp;</label>
            <div class="area">
                <input type="text" placeholder="请输入算法名称" id="algo_name" value="{{$an}}"/>
            </div>
            <label class="label">算法ID&nbsp;&nbsp;</label>
            <div class="area">
                <select class="camsSelect" id="skill_id">
                    <option {{if eq $sk ""}}selected{{end}} value="">--请选择--</option>
                    {{range $coindex,$rowv := .skillIds}}
                        <option {{if eq $sk $rowv.SkillId}}selected="selected"{{end}}
                                value={{$rowv.SkillId }}>
                            {{$rowv.SkillId}}
                        </option>
                    {{end}}

                </select>
                {{/*                    <input type="text" placeholder="请输入算法ID" id="skill_id" value="{{.sk}}">*/}}
            </div>
            <div>
                <input type="button" onclick="searchAlgoList()" class="form_btn" value='查询'/>
            </div>
            <div>
                <input type="button" onclick="searchreset()" class="form_btn" value='重置'/>
            </div>

            <div>
                <input type="button" onclick="addAlgo()" class="form_btn" value='新增'/>
            </div>
        </form>


    </div>
</div>
<div class="tableout">
    <table class="tab_algo">
        <thead>
        <tr class="tab_rows1">

            <th style="width:60px;text-align: center" align="center">序号</th>
            <th style="width: 5%" align="center">ID</th>
            <th style="width: 5%">算法ID</th>
            <th style="width:8%;">模型ID</th>
            <th style="width: 12%;">算法名称</th>
{{/*            <th style="width: 12%;">镜像名称</th>*/}}
{{/*            <th style="width: 12%;">启动命令</th>*/}}
            <th style="width:15%">启动服务器</th>
            <th style="width:8%">状态</th>
            <th style="width:8%">操作结果</th>
            <th style="width:26%">算法容器ID</th>
            <th style="width:10%">最后更新时间</th>
            <th width="120px" style="text-align: center;">操作</th>
            {{/*                <th style="width: 10px" align="center"></th>*/}}
        </tr>
        </thead>
        <tbody>

        {{range $index,$vo := .list}}
            {{if IsOdd $index}}
                <tr class="rows_restodd">
            {{else}}
                <tr class="rows_resteven">
            {{end}}
            <td align="center">{{$vo.No}}</td>
            <td style="width: 12px" align="left">
                <a class="detailhref" href="/algoinfoconfig/add?t={{$t}}&id={{$vo.Id}}">{{$vo.Id}}</a>
            </td>
            <td class="table_content"> {{$vo.SkillId}}</td>
            <td class="line-heightcss"> {{$vo.ModelId}}</td>
            <td class="line-heightcss"> {{$vo.AlgoName}}</td>
{{/*            <td class="line-heightcss"> {{$vo.ImageAddr}}</td>*/}}
{{/*            <td class="line-heightcss"> {{$vo.Cmd}}</td>*/}}
            <td style="text-align: left"> {{$vo.NodeSelector}}</td>
            <td>  {{if eq $vo.AlgoStatus "1"}}<p class="running"> 运行中
                {{else if eq  $vo.AlgoStatus "0"}}<p class="stopped">已停止
                {{else if eq  $vo.AlgoStatus "2"}}<p class="starting">正在启动
                {{else if eq  $vo.AlgoStatus "3"}}<p class="stopping">正在停止
                {{else if eq  $vo.AlgoStatus "4"}}<p class="running">待处理
                {{else if eq  $vo.AlgoStatus "5"}}<p class="running">部分成功
                {{else if eq  $vo.AlgoStatus "6"}}<p class="stopped">启动失败
                {{else if eq  $vo.AlgoStatus "7"}}<p class="stopped">停止失败
                    {{else}} <p class="unknown"> 未知</p>{{end}}</td>
            <td> {{if eq $vo.AlgoStatus "1"}}启动成功{{else if eq $vo.AlgoStatus "0"}}停止成功{{else}}请到详情页查看结果{{end}}</td>
            <td class="line-heightcss">
                <a class="table_content"
                   href="/algo/list?t={{$t}}&model_id={{$vo.ModelId}}">{{$vo.Cids}}</a>
            </td>
            <td class="line-heightcss"> {{$vo.UpdateTime}}</td>
            <td class="td_left">
                <a class="viewcss" title="详情"
                   href="/algoinfoconfig/add?t={{$t}}&id={{$vo.Id}}"> </a>
                <a title="删除" href="/algoinfoconfig/del?id={{$vo.Id}}&t={{$t}}&p={{Add $PageNo 1}}"
                   class="tab_delicon"> </a>
                {{ if eq  $vo.AlgoStatus "2"}}<a class="tab_pause" title="中止"
                                                 href="/algoinfoconfig/stopfor?t={{$t}}&id={{$vo.Id}}"> </a>{{end}}
                <a class="tab_start" title="启动"
                                                           href="/algoinfoconfig/startbyhand?t={{$t}}&id={{$vo.Id}}"> </a>
{{/*                {{ if Contains  "1，7"  $vo.AlgoStatus}}<a class="tab_stop" title="停止"*/}}
{{/*                                                          href="/algoinfoconfig/stopbyhand?t={{$t}}&id={{$vo.Id}}"> </a>{{end}}*/}}

            </td>
            </tr>
        {{end}}
        </tbody>
    </table>
</div>
<div id="bgmask">
    <img class="zhezhao" src="/static/img/loading.gif">
</div>
<div class="box-footer">
    <div id="page_extra">
        {{.Page.TotalCount}}条 <span id="page_num">共{{.Page.TotalPage}}</span>页
        <input type="text" id="page_skip" placeholder='跳转页' autocomplete="off"/>
        <button id="page_sBtn">Go</button>
    </div>
    <ul class="page-nav" id="page"></ul>
</div>
</body>
</div>
<script src="/static/js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap-paginator.min.js"></script>
<script src="/static/js/fSelect.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script type="text/javascript" src="/static/js/ajaxfileupload.js"></script>
<script>
    function searchAlgoList() {
        var sk = $('#skill_id').val();
        var an = $('#algo_name').val();
        window.location = '/algoinfoconfig/list?t=' + {{.t}} +'&sk=' + sk + '&an=' + an
    }

    function searchreset() {
        $('#skill_id').val("")
        $('#algo_name').val("");
        window.location = '/algoinfoconfig/list?t=' + {{.t}}
    }

    function addAlgo() {
        // window.location = '/algo/addmore'
        window.location = '/algoinfoconfig/add?t={{.t}}'

    }

    function sysConfig() {
        window.location = '/algoinfoconfig/sysconf'

    }

    $(document).ready(function () {
        var total = "{{.Page.TotalPage}}";
        var curPage = '{{.Page.PageNo}}';
        var tipArr = ['请输入正确页码！', '页数输入错误!', '已经是当前页!'];

        function hrefn(page) {
            var as = $('#AsyncStatus')[0].checked ? "1" : "0";
            window.location.href = '/algoinfoconfig/list?t={{.t}}&sk={{.sk}}&p=' + page
        }

        CommonJs.page(total, curPage, tipArr, hrefn);

        function showdiv() {
            document.getElementById("bgmask").style.display = "block";
            /* document.getElementById("showF").style.display ="block";*/
        }

        $(".tab_delicon").click(function () {
            return confirm("确定要删除此记录吗？");
        });

        function hidediv() {
            document.getElementById("bgmask").style.display = 'none';
            /*document.getElementById("show").style.display ='none';*/
        }


    })
</script>
</html>
